<script>
  (function () {
    var cx = {% if page.slug == 'knowledge_base' %} '{{site.google_custom_kb_search}}' {% else %} '{{site.google_custom_search}}' {% endif %};
  var gcse = document.createElement('script');
  gcse.async = true;
  gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
    '//www.google.com/cse/cse.js?cx=' + cx;
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(gcse, s);
  })();

</script>

<div id="page-search">
  <script src="http://www.google.com/jsapi"></script>
  {% javascript search %}

  <script>
    $(document).ready(function () {
    var propertyNames = {% case page.res_type %} {% when 'kb' %} ['kb'] {% else %} ['docs', 'api', 'kb'] {% endcase %}
    for(var i = 0; i < propertyNames.length; i++) {
      viewModel.set(propertyNames[i], true);
    }
    viewModel.updateLabel();
})
  </script>

  <div id="refine-search-popup" style="display: none">
    <ul>
      <li>
        <label class="custom-checkbox unselectable"><input type="checkbox" {% if page.res_type != 'kb' and page.res_type != 'api' %} disabled="true" {% endif %} data-bind="checked: docs" /><span class="k-icon k-i-check"></span>Search in Documentation</label>
      </li>
      <li>
        <label class="custom-checkbox unselectable"><input type="checkbox" {% if page.res_type == 'kb' %} disabled="true" {% endif %} data-bind="checked: kb" /><span class="k-icon k-i-check"></span>Search in Knowledge Base</label>
      </li>
      <li>
        <label class="custom-checkbox unselectable"><input type="checkbox" {% if page.res_type == 'api' %} disabled="true" {% endif %} data-bind="checked: api" /><span class="k-icon k-i-check"></span>Search in API Reference</label>
      </li>
    </ul>
  </div>
  <div class="gcse-search" data-gname="google-search"></div>
</div>